/*
 * The main entry
 */
#include <stdio.h>
#include "wffs_format.h"
#include "nand.h"
#include "sim_vfs.h"
#include "wffs_super.h"


#define NAND_FLASH_SIZE             32 * 1024 * 1024
#define NAND_FLASH_PAGE_SIZE        2048
#define NAND_FLASH_ERASE_SIZE       NAND_FLASH_PAGE_SIZE * 64
#define NAND_FLASH_BLOCK_GROUP_SIZE 0 /*0 means block group auto caculate*/

struct flash_descriptor flash_d;

int main(int argc, char *argv[])
    {
    int ret;

    /*flash parameter init*/
    flash_d.size       = NAND_FLASH_SIZE;
    flash_d.page_size  = NAND_FLASH_PAGE_SIZE;
    flash_d.erase_size = NAND_FLASH_ERASE_SIZE;

    /*flash setup*/
    ret = flash_setup(&flash_d);
    if (!ret)
        {
        printf("--flash setup success--\n");
        }
    else
        {
        printf("--flash setup failed--\n");
        return(-1);
        }

    /*format flash*/
    ret = wffs_format(&flash_d, NAND_FLASH_SIZE, NAND_FLASH_PAGE_SIZE, 
                      NAND_FLASH_ERASE_SIZE, NAND_FLASH_BLOCK_GROUP_SIZE);
    if (!ret)
        {
        printf("--wrs flash filesystem format success--\n");
        }
    else
        {
        printf("--wrs flash filesystem format failed--\n");
        return(-1);
        }

    #if 0
    /*register wffs hook*/
    ret = init_wffs();
    if (!ret)
        {
        printf("--wffs init success--\n");
        }
    else
        {
        printf("--wffs init failed--\n");
        return(-1);
        }
    /*mount wffs*/
    ret = smount(0);
    if (!ret)
        {
        printf("--Mount was succesful--\n");
        }
    else
        {
        printf("--Mount was failed--\n");
        return(-1);
        }               
    #endif
    /*do sth.*/

    return(0);
    }
